home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
081-090
/
amok81
/
m2
/
talkdemo
/
txt
/
talker.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
5KB
|
213 lines
MODULE Talker;
(*$ LargeVars:=FALSE StackParms:=FALSE *)
FROM SYSTEM IMPORT ADR,ADDRESS,CAST,TAG,LONGSET;
FROM Requester IMPORT SetWindow,OKRequest;
FROM String IMPORT Length,Copy;
IMPORT A:Arts,
ID:IntuitionD,
IL:IntuitionL,
GD:GadToolsD,
GL:GadToolsL,
ED:ExecD,
EL:ExecL,
N:Narrator,
TB:TalkBase,
TM:TalkMenu,
TG:TalkGadgets,
TN:TalkNarrator,
TF:TalkFile;
TYPE
Str127Ptr=POINTER TO TB.Str127;
Str255Ptr=POINTER TO TB.Str255;
PROCEDURE Talk; FORWARD;
PROCEDURE DoMenu(e:TM.ExtItemPtr);
BEGIN
IF e=NIL THEN
RETURN
ELSE
CASE TM.MenuAction(e^.user) OF
| TM.openPhonID:
TF.LoadPhonemes;
| TM.openVoiceID:
TF.LoadVoice;
| TM.savePhonID:
TF.SavePhonemes;
| TM.saveVoiceID:
TF.SaveVoice;
| TM.talkID:
Talk;
| TM.aboutID:
TB.SetBusy(TRUE);
OKRequest(
" Narrator37 Demo V1.1\n"+
"© 1992 Bernd Preusing, AMSoft\n"+
" Written with M2Amiga V4.1");
TB.SetBusy(FALSE);
| TM.quitID:
TB.quit:=TRUE;
| TM.resetID:
TG.SetNarr(TB.defNarr);
| TM.iconID:
TB.saveIcons:=ID.checked IN e^.m.flags;
END;
END;
END DoMenu;
PROCEDURE DoSlider(g:ID.GadgetPtr;code:CARDINAL);
BEGIN
CASE TG.Gadgets(g^.gadgetID) OF
| TG.rate: TB.myNarr.rate:=code;
| TG.pitch: TB.myNarr.pitch:=code;
| TG.volume: TB.myNarr.volume:=code;
| TG.sampFreq:TB.myNarr.sampFreq:=code;
| TG.f0Enth: TB.myNarr.f0Enthusiasm:=code;
| TG.f0Perturb:TB.myNarr.f0Perturb:=code;
| TG.f1Adj: TB.myNarr.f1Adj:=CAST(INTEGER,code);
| TG.f2Adj: TB.myNarr.f2Adj:=CAST(INTEGER,code);
| TG.f3Adj: TB.myNarr.f3Adj:=CAST(INTEGER,code);
| TG.a1Adj: TB.myNarr.a1Adj:=CAST(INTEGER,code);
| TG.a2Adj: TB.myNarr.a2Adj:=CAST(INTEGER,code);
| TG.a3Adj: TB.myNarr.a3Adj:=CAST(INTEGER,code);
| TG.articulate:TB.myNarr.articulate:=code;
| TG.avBias: TB.myNarr.avBias:=CAST(INTEGER,code);
| TG.afBias: TB.myNarr.afBias:=CAST(INTEGER,code);
| TG.priority:TB.myNarr.priority:=CAST(INTEGER,code);
| TG.centralize:TB.myNarr.centralize:=CAST(INTEGER,code);
IF code=0 THEN
TG.Disable(TG.centphon);
ELSE
TG.Enable(TG.centphon);
END;
END;
END DoSlider;
PROCEDURE EmptyPort(p:ED.MsgPortPtr):BOOLEAN;
BEGIN
IF p#NIL THEN
RETURN p^.msgList.head^.succ=NIL;
ELSE
RETURN TRUE;
END;
END EmptyPort;
VAR
aborted:BOOLEAN;
PROCEDURE DoIntui():BOOLEAN;
VAR
imp:ID.IntuiMessagePtr;
class:ID.IDCMPFlagSet;
code:CARDINAL;
g:ID.GadgetPtr;
mi:TM.ExtItemPtr;
si:ID.StringInfoPtr;
id:INTEGER;
BEGIN
imp:=GL.GTGetIMsg(TB.myWindow^.userPort);
IF imp#NIL THEN
class:=imp^.class;
code:=imp^.code;
g:=imp^.iAddress;
GL.GTReplyIMsg(imp);
IF class=ID.IDCMPFlagSet{ID.menuPick} THEN
IF ~TN.talking THEN
WHILE ~TB.quit & (code#ID.menuNull) DO
mi:=CAST(TM.ExtItemPtr,IL.ItemAddress(TM.myMenu,code));
DoMenu(mi);
code:=mi^.m.nextSelect;
END;
END;
ELSE (* Gadget *)
id:=g^.gadgetID;
IF class<=ID.IDCMPFlagSet{ID.gadgetUp,ID.gadgetDown,ID.mouseMove} THEN
CASE id OF
| ORD(TG.rate)..ORD(TG.centralize):
DoSlider(g,code);
| ORD(TG.mode):
TB.myNarr.mode:=code;
| ORD(TG.sex):
TB.myNarr.sex:=code;
| ORD(TG.centphon): (* MX *)
TG.SetCentPhone(TB.CentrPhons(code));
| ORD(TG.speak):
Talk;
| ORD(TG.text):
si:=CAST(ID.StringInfoPtr,g^.specialInfo);
Copy(TB.textBuff,CAST(Str127Ptr,si^.buffer)^);
IF TN.Translate() THEN
TG.UpdatePhonemes;
ELSE
TB.SetBusy(TRUE);
OKRequest("Translate error");
TB.SetBusy(FALSE);
END;
| ORD(TG.phonemes):
si:=CAST(ID.StringInfoPtr,g^.specialInfo);
Copy(TB.phonBuff,CAST(Str255Ptr,si^.buffer)^);
Talk;
| ORD(TG.abort):
aborted:=TRUE;
END;
END;
END; (* class *)
END; (* idcmp#NIL *)
RETURN aborted;
END DoIntui;
PROCEDURE Talk;
BEGIN
IF ~TN.talking THEN
aborted:=FALSE;
INCL(TB.myWindow^.flags,ID.rmbTrap);
TG.Enable(TG.abort);
TG.Disable(TG.speak); (* vermeide unendliche Rekursion! *)
TN.DoTalk(DoIntui);
TG.Enable(TG.speak);
TG.Disable(TG.abort);
EXCL(TB.myWindow^.flags,ID.rmbTrap);
END;
END Talk;
PROCEDURE DoLoop;
BEGIN
WHILE ~TB.quit DO
EL.WaitPort(TB.myWindow^.userPort);
IF DoIntui() THEN END;
END; (* WHILE *)
END DoLoop;
VAR
si:ID.StringInfoPtr;
BEGIN
TB.quit:=FALSE;
SetWindow(TB.myWindow);
TG.SetCentPhone(MIN(TB.CentrPhons));
TG.SetNarr(TB.defNarr); (* von Narr gesetzt *)
IL.ModifyIDCMP(TB.myWindow,TG.idcmpFlags+TM.idcmpFlags);
TG.Disable(TG.abort);
(* Willkommensgruss *)
si:=CAST(ID.StringInfoPtr,TG.gadgets[TG.text]^.specialInfo);
Copy(TB.textBuff,CAST(Str127Ptr,si^.buffer)^);
IF TN.Translate() THEN
TG.UpdatePhonemes;
Talk;
END;
DoLoop;
CLOSE
END Talker.